package com.fuluwa.domain.category.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.alibaba.fastjson.annotation.JSONField;

@Entity
@Table(name = "t_category")
public class Category {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@JSONField(name = "cid")
	private Long id; // 自增ID

	@JSONField(name = "pcid")
	private long parent;

	@Column(nullable = false)
	private String name; // 类目名称

	@Column(columnDefinition = "SMALLINT default 0")
	private int type; // 属性类型

	@Column(columnDefinition = "bigint default 0")
	private long propety; // 属性标记

	@Column(columnDefinition = "varchar(512) default 0")
	private String desc; // 属性值描述

	@Column(columnDefinition = "int default 0")
	private int order; // 属性值排序

	@Column(columnDefinition = "TINYINT default 0")
	private short hasAttr; // 是否有属性

	@Column(columnDefinition = "TINYINT default 0")
	private short status;

	@Transient
	List<Category> list = new ArrayList<Category>();

	public List<Category> getList() {
		return list;
	}

	public void setList(List<Category> list) {
		this.list = list;
	}

	public Category() {
	}

	public Category(long cid, String name) {
		this.id = cid;
		this.name = name;
	}

	public Category(long pcid, long cid, String name) {
		this.parent = pcid;
		this.id = cid;
		this.name = name;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public long getParent() {
		return parent;
	}

	public void setParent(long parent) {
		this.parent = parent;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public long getPropety() {
		return propety;
	}

	public void setPropety(long propety) {
		this.propety = propety;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public short getHasAttr() {
		return hasAttr;
	}

	public void setHasAttr(short hasAttr) {
		this.hasAttr = hasAttr;
	}

	public short getStatus() {
		return status;
	}

	public void setStatus(short status) {
		this.status = status;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
